THashTable< T > Class Template Reference
[Template Containers]

Hash Table templateA hash table is a list of buckets. More...

#include <thashtable.h>

Inheritance diagram for THashTable< T >:
Inheritance graph
[legend]

Public Types

typedef uint32(* THashFunc )(const T &, uint32)
 Hash function type.

Public Member Functions

 THashTable (THashFunc, int32=10)
 Constructor with hash function.
 THashTable (const THashTable< T > &)
 Copy constructor.
 THashTable (THashFunc, const TContainer< T > &)
 Constructor with container.
 ~THashTable ()
 Destructor.
THashTable< T > & operator= (const THashTable< T > &)
 Assignment operator, uses copy.
void setHashFunction (THashFunc)
 Set hash function.
bool resize (int32)
 Resize the table, set number of hash buckets.
virtual TContainer< T > * newInstance () const
virtual int32 total () const
virtual bool isEmpty () const
virtual bool add (const T &item)
virtual bool remove (const T &item)
virtual bool remove (const TIterator< T > &iter)
virtual bool removeAt (int32 index)
virtual void removeAll ()
virtual T & lookup (const T &item) const
virtual bool contains (const T &item) const
virtual int32 occurrences (const T &item) const
virtual TIterator< T > * newIterator () const

Detailed Description

template<class T>
class Steinberg::THashTable< T >

Hash Table template

A hash table is a list of buckets.

It assigns values to items (template) using a hash function and puts them into the bucket, which table index equals the item's calculated value.

See also:
TContainer, THashTableIterator, THashSet

Member Typedef Documentation

typedef uint32(* THashFunc)(const T &, uint32)

Hash function type.

Reimplemented in TBag< T >, THashDictionary< TKey, TObject >, and THashSet< T >.


Constructor & Destructor Documentation

THashTable ( THashFunc  func,
int32  size = 10 
) [inline]

Constructor with hash function.

Parameters:
[in] func Hash function the table uses.
[in] size Size (number of buckets) of new table.
THashTable ( const THashTable< T > &  table  )  [inline]

Copy constructor.

Parameters:
[in] table Hash table to copy.
THashTable ( THashFunc  func,
const TContainer< T > &  cont 
) [inline]

Constructor with container.

Parameters:
[in] func Hash function the table uses.
[in] cont Container to construct the table from.
~THashTable (  )  [inline]

Destructor.


Member Function Documentation

THashTable< T > & operator= ( const THashTable< T > &  table  )  [inline]

Assignment operator, uses copy.

Parameters:
[in] table Assign left side (this) to table.
Returns:
Assigned hash table.
void setHashFunction ( THashFunc  func  )  [inline]

Set hash function.

Parameters:
[in] func New hash function.
bool resize ( int32  newsize  )  [inline]

Resize the table, set number of hash buckets.

Parameters:
[in] newsize New number of hash buckets.
Returns:
true, if resized.
false, if failed.
TContainer< T > * newInstance (  )  const [inline, virtual]

Create a copy of this container.

Returns:
New hash table instance.

Implements TContainer< T >.

int32 total (  )  const [inline, virtual]

Return number of items.

Returns:
Total number of items in the table.

Reimplemented from TContainer< T >.

bool isEmpty (  )  const [inline, virtual]

Is container empty?

Returns:
true, if empty.
false, if not empty.

Reimplemented from TContainer< T >.

bool add ( const T &  rObj  )  [inline, virtual]

Add item to container.

Parameters:
[in] rObj Item to add.
Returns:
true, if added.
false, if failed.

Implements TContainer< T >.

Reimplemented in TBag< T >, and THashSet< T >.

bool remove ( const T &  rObj  )  [inline, virtual]

Remove equal item.

Parameters:
[in] rObj Item to remove.
Returns:
true, if removed.
false, if failed.

Implements TContainer< T >.

Reimplemented in TBag< T >.

bool remove ( const TIterator< T > &  iter  )  [inline, virtual]

Remove item at current iterator position.

Parameters:
[in] iter Points to item to remove.
Returns:
true, if removed.
false, if failed.

Implements TContainer< T >.

bool removeAt ( int32  idx  )  [inline, virtual]

Remove item at given index.

Parameters:
[in] idx Index of item to remove.
Returns:
true, if removed.
false, if failed.

Implements TContainer< T >.

void removeAll (  )  [inline, virtual]

Remove all items from list.

Implements TContainer< T >.

Reimplemented in TBag< T >.

T & lookup ( const T &  rObj  )  const [inline, virtual]

Searches for the item equal to the specified item in the list and returns the first occurrence.

Parameters:
[in] rObj Item to look up.
Returns:
true, if removed.
false, if failed.

Reimplemented from TContainer< T >.

bool contains ( const T &  rObj  )  const [inline, virtual]

See if container has equal item.

Parameters:
[in] rObj Item to compare.
Returns:
true, if equal item exists.
false, if no equal item exists.

Reimplemented from TContainer< T >.

int32 occurrences ( const T &  rObj  )  const [inline, virtual]

Count occurrences of equal items.

Parameters:
[in] rObj Item to compare.
Returns:
number of equal items.

Reimplemented from TContainer< T >.

TIterator< T > * newIterator (  )  const [inline, virtual]

Create container iterator instance.

Returns:
New hash table iterator.

Implements TContainer< T >.

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Empty

Copyright ©2013 Steinberg Media Technologies GmbH. All Rights Reserved.